<!DOCTYPE html>
<html>

<head>
    <title>{{ title }} - 学生成绩管理系统</title>
    <link rel="stylesheet" href="/static/css/home.css">
    <link rel="stylesheet" href="/static/css/forms.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
    <!-- 顶部导航栏 -->
    <nav class="top-nav">
        <div class="nav-content">
            <a href="/" class="logo">学生成绩管理系统</a>
            <div class="user-info">
                <span class="welcome-text">欢迎，{{ request.user.username }}</span>
                <a href="{% url 'accounts:logout' %}" class="logout-btn">退出登录</a>
            </div>
        </div>
    </nav>

    <div class="container">
        <main class="main-content">
            <h1 class="page-title">{{ title }}</h1>

            {% if messages %}
            <div class="messages">
                {% for message in messages %}
                <div class="message {{ message.tags }}">
                    {{ message }}
                </div>
                {% endfor %}
            </div>
            {% endif %}

            <div class="form-container">
                <form method="post">
                    {% csrf_token %}
                    {% for field in form %}
                    <div class="form-group">
                        <label class="form-label" for="{{ field.id_for_label }}">{{ field.label }}</label>
                        {{ field }}
                        {% if field.help_text %}
                        <small class="help-text">{{ field.help_text }}</small>
                        {% endif %}
                        {% if field.errors %}
                        <div class="error-message">
                            {{ field.errors.0 }}
                        </div>
                        {% endif %}
                    </div>
                    {% endfor %}
                    <div class="form-buttons">
                        <a href="{% url 'teachers:teacher_list' %}" class="btn-cancel">取消</a>
                        <button type="submit" class="btn-submit">保存</button>
                    </div>
                </form>
            </div>
        </main>
    </div>
</body>

</html>